﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebRole1
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated == false)
            {
                Session["isAdmin"] = false;
            }
            Page_Init(sender, e);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
          
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            try
            {
                NavigationMenu.Items.Clear();

                MenuItem mnuHome = new MenuItem();
                mnuHome.NavigateUrl = "default.aspx";
                mnuHome.Text = "Home";
                mnuHome.Value = "Home";
                NavigationMenu.Items.Add(mnuHome);


                MenuItem mnuAbout = new MenuItem();
                mnuAbout.NavigateUrl = "about.aspx";
                mnuAbout.Text = "About";
                mnuAbout.Value = "About";
                NavigationMenu.Items.Add(mnuAbout);

                if ((bool)Session["isAdmin"] == true)
                {
                    //Construct the menus for the ADMIN
                    MenuItem mnuAdmin = new MenuItem();
                    //mnuAdmin.NavigateUrl = "Administration.aspx";
                    mnuAdmin.Text = "Administration";
                    mnuAdmin.Value = "Administration";
                    NavigationMenu.Items.Add(mnuAdmin);

                    MenuItem mnuManageUser = new MenuItem();
                    mnuManageUser.NavigateUrl = "manageUser.aspx";
                    mnuManageUser.Text = "Manage Users";
                    mnuManageUser.Value = "ManageUsers";
                    mnuAdmin.ChildItems.Add(mnuManageUser);

                    MenuItem mnuManagePatient = new MenuItem();
                    mnuManagePatient.NavigateUrl = "managePatient.aspx";
                    mnuManagePatient.Text = "Manage Patients";
                    mnuManagePatient.Value = "ManagePatients";
                    mnuAdmin.ChildItems.Add(mnuManagePatient);

                    MenuItem mnuManageExe = new MenuItem();
                    mnuManageExe.NavigateUrl = "manageGame.aspx";
                    mnuManageExe.Text = "Manage EXE";
                    mnuManageExe.Value = "ManageEXE";
                    mnuAdmin.ChildItems.Add(mnuManageExe);

                    MenuItem mnuManageGamePlay = new MenuItem();
                    mnuManageGamePlay.NavigateUrl = "manageGamePlay.aspx";
                    mnuManageGamePlay.Text = "Manage GamePlay";
                    mnuManageGamePlay.Value = "ManageGamePlay";
                    mnuAdmin.ChildItems.Add(mnuManageGamePlay);


                    MenuItem mnuAddPatient = new MenuItem();
                    //mnuAdmin.NavigateUrl = "Administration.aspx";
                    mnuAddPatient.Text = "Add Patient";
                    mnuAddPatient.Value = "Patient";
                    NavigationMenu.Items.Add(mnuAddPatient);

                    MenuItem mnuManageNewPatient = new MenuItem();
                    mnuManageNewPatient.NavigateUrl = "patients.aspx";
                    mnuManageNewPatient.Text = "New Patients";
                    mnuManageNewPatient.Value = "newpatients";
                    mnuAddPatient.ChildItems.Add(mnuManageNewPatient);

                    MenuItem mnuManageNewPatient1 = new MenuItem();
                    mnuManageNewPatient1.NavigateUrl = "aPatients.aspx";
                    mnuManageNewPatient1.Text = "New A Patients";
                    mnuManageNewPatient1.Value = "newApatients";
                    mnuAddPatient.ChildItems.Add(mnuManageNewPatient1);
                }
            }
            catch (Exception) { }
        }
    }
}
